package com.kingint.web.sys.controller;



import com.kingint.mbg.sys.entity.UmsMember;
import com.kingint.web.domain.MemberDetails;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContext;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.stereotype.Controller;

@Controller
public class BaseController {
	public UmsMember getCurrentUser() {
		try {
			SecurityContext ctx = SecurityContextHolder.getContext();
			Authentication auth = ctx.getAuthentication();
			MemberDetails memberDetails = (MemberDetails) auth.getPrincipal();
			return memberDetails.getUmsMember();
		}catch (Exception e){
			return new UmsMember();
		}
	}
}